package com.sanpu.kxe.business.trade.view;

import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.sanpu.kxe.R;
import com.sanpu.kxe.base.BaseTitleActivity;
import com.sanpu.kxe.business.trade.bean.TransactionOutput;
import com.sanpu.kxe.business.trade.contract.TradeConfig;
import com.sanpu.kxe.common.utils.CommonUtils;

import butterknife.Bind;

/**
 * Description：账单详情
 * Created by 薛勇军 on 2018/8/27.
 */

public class TransactionDetailsActivity extends BaseTitleActivity {

    @Bind(R.id.transaction_id)
    TextView vTransactionId;
    @Bind(R.id.amount)
    TextView vAmount;
    @Bind(R.id.state)
    TextView vState;
    @Bind(R.id.type)
    TextView vType;
    @Bind(R.id.time)
    TextView vTime;
    @Bind(R.id.merchant)
    TextView vMerchant;
    @Bind(R.id.fee)
    TextView vFee;
    @Bind(R.id.fee_layout)
    LinearLayout vFeeLayout;
    @Bind(R.id.fee_title)
    TextView vFeeTitle;
    @Bind(R.id.icon)
    ImageView vIcon;
    @Bind(R.id.rat)
    TextView vRat;

    @Bind(R.id.phone_number)
    TextView vPhoneNumber;
    @Bind(R.id.charger_name)
    TextView vChargerName;
    @Bind(R.id.recharger_tel)
    LinearLayout vRechargerTel;
    @Bind(R.id.tran_des_layout)
    LinearLayout vTranDesLayout;

    @Bind(R.id.max_fee_layout)
    RelativeLayout vMaxFeeLayout;
    @Bind(R.id.max_fee)
    TextView vMaxFee;

    @Bind(R.id.crdNoLayout)
    RelativeLayout crdNoLayout;
    @Bind(R.id.stlCrdNoLayout)
    RelativeLayout stlCrdNoLayout;
    @Bind(R.id.crdNoTv)
    TextView crdNoTv;
    @Bind(R.id.stlCrdNoTv)
    TextView stlCrdNoTv;

    @Bind(R.id.rspMsgLayout)
    RelativeLayout rspMsgLayout;
    @Bind(R.id.rspMsgTv)
    TextView rspMsgTv;

    @Override
    protected int getLayoutResID() {
        return R.layout.activity_transation_details;
    }

    @Override
    protected void initView() {
        super.initView();
        commonTitle.setTitle("交易详情");
    }

    @Override
    protected void initData() {
        super.initData();
        TransactionOutput output =
                (TransactionOutput) getIntent().getSerializableExtra(TradeConfig.INTENT_TRANSACTION);
        if (output != null) {
            try {
                vTransactionId.setText("流水号： " + output.getTransctionId() + "");
                if (!TextUtils.isEmpty(output.getAmount())) {
                    vAmount.setText(output.getAmount());
                }
                if (!TextUtils.isEmpty(output.getHandlingFee())) {
                    vRat.setText(output.getHandlingFee());
                } else {
                    vRat.setText("0");
                }
                if (!TextUtils.isEmpty(output.getPayFee())) {
                    vFee.setText("" + output.getPayFee() + "元");
                } else {
                    vFee.setText("0元");
                }
                if (!TextUtils.isEmpty(output.getTransactionName())) {
                    vType.setText(output.getTransactionName());
                }
                if (!TextUtils.isEmpty(output.getCreateTime())) {
                    vTime.setText(output.getCreateTime());
                }
                if (!TextUtils.isEmpty(output.getMerchantName())) {
                    vMerchant.setText(output.getMerchantName());
                }
                if (!TextUtils.isEmpty(output.getPayStatus())) {
                    vState.setText(output.getPayStatus());
                }
                vIcon.setBackgroundResource(CommonUtils.getPayDrawable(output.getPayType()));
                if (!TextUtils.isEmpty(output.getTradingCard())) {
                    crdNoLayout.setVisibility(View.VISIBLE);
                    crdNoTv.setText(output.getTradingCard());
                } else {
                    crdNoLayout.setVisibility(View.GONE);
                }
                if (!TextUtils.isEmpty(output.getSettleCard())) {
                    stlCrdNoLayout.setVisibility(View.VISIBLE);
                    stlCrdNoTv.setText(output.getSettleCard());
                } else {
                    stlCrdNoLayout.setVisibility(View.GONE);
                }
                if (!TextUtils.isEmpty(output.getFallCause())) {
                    rspMsgLayout.setVisibility(View.VISIBLE);
                    rspMsgTv.setText(output.getFallCause());
                } else {
                    rspMsgLayout.setVisibility(View.GONE);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    @Override
    protected boolean hasBindEventBus() {
        return false;
    }
}
